package com.amani.module.medical_supplies.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 三方大配置文件
 * <p>
 * date      18/07/30 20:11
 *
 * @author 吴书华
 * @version 1.0
 */
@Component
@PropertySource(value = "application-sfd.properties",encoding = "utf-8")
@ConfigurationProperties(prefix="sfd")
public class SFDConstant {

    // 虚拟路径
    public static String VIRTUAL_PATH;
    // 虚拟路径url前缀
    public static String VIRTUAL_PATH_PRE;
    // 打印模板目录
    public static String JXLS_TEMPLATE_DIR;
    // 打印输出目录
    public static String JXLS_OUT_DIR;
    /**
     * 调拨--出库类型
     */
    public static int allocation_outStorage_type;
    /**
     *调拨--入库类型
     */
    public static int allocation_inStorage_type;
    /**
     * 调拨--复核调拨单状态
     */
    public static int allocation_review;
    /**
     * 调拨--上架调拨单状态
     */
    public static int allocation_shelves;
    /**
     * 不是唯一码监管
     */
    public static int not_unique_code_supervision;
    /**
     * 唯一码监管
     */
    public static int unique_code_supervision;
    /**
     * 出库复核--差异原因：无货
     */
    public static int outStockApproval_not_good;
    /**
     * 出库复核--已复核
     */
    public static int outStockApproval_review;
    /**
     * 分仓
     */
    public static int separate_warehouse;
    /**
     * 总仓
     */
    public static int total_warehouse;



    // 订单前缀
    public static Map<String, String> ORDER_PRE;

    private Map<String, String> ordePprefix;

    public static Map<String,String> JXLS_TEMPLATE;

    private Map<String,String> jxlsTemplate;

    @Value("${virtual-path}")
    public void setVPath(String value) {
        SFDConstant.VIRTUAL_PATH = value;
    }

    @Value("${virtual-path-url.pre}")
    public void setVPathPre(String value) {
        SFDConstant.VIRTUAL_PATH_PRE = value;
    }

    @Value("${jxls-template-dir}")
    public void setJXLSTemplatePath(String value) {
        SFDConstant.JXLS_TEMPLATE_DIR = value;
    }

    @Value("${jxls-out-dir}")
    public void setJXLSOutPath(String value) {
        SFDConstant.JXLS_OUT_DIR = value;
    }

    @Value("${allocation-outstorage-type}")
    public void setAllocationOutStorageType(int value){
        SFDConstant.allocation_outStorage_type = value;
    }
    @Value("${allocation-instorage-type}")
    public void setAllocationInStorageType(int value){
        SFDConstant.allocation_inStorage_type = value;
    }
    @Value("${not-unique-code-supervision}")
    public void setNotUniqueCodeSupervision(int value){
        SFDConstant.not_unique_code_supervision = value;
    }
    @Value("${unique-code-supervision}")
    public void setUniqueCodeSupervision(int value){
        SFDConstant.unique_code_supervision = value;
    }
    @Value("${outStockApproval-not-good}")
    public void setOutStockApprovalNotGood(int value){
        SFDConstant.outStockApproval_not_good = value;
    }
    @Value("${separate-warehouse}")
    public void separateWarehouse(int value){
        SFDConstant.separate_warehouse = value;
    }
    @Value("${total-warehouse}")
    public void setTotalWarehouse(int value){
        SFDConstant.total_warehouse = value;
    }
    @Value("${allocation-review}")
    public void setAllocationReview(int value){
        SFDConstant.allocation_review = value;
    }
    @Value("${allocation-shelves}")
    public void setAllocationShelves(int value){
        SFDConstant.allocation_shelves = value;
    }
    @Value("${outStockApproval-review}")
    public void setOutStockApprovalReview(int value){
        SFDConstant.outStockApproval_review = value;
    }

    @Bean
    public SFDConstant setOrderPre(SFDConstant config){
        SFDConstant.ORDER_PRE = config.ordePprefix;
        SFDConstant.JXLS_TEMPLATE=config.jxlsTemplate;
        return config;
    }
    public Map<String, String> getOrderPrefix() {
        return ordePprefix;
    }

    public void setOrderPrefix(Map<String, String> orderPrefix) {
        this.ordePprefix = orderPrefix;
    }

    public Map<String, String> getJxlsTemplate() {
        return jxlsTemplate;
    }

    public void setJxlsTemplate(Map<String, String> jxlsTemplate) {
        this.jxlsTemplate = jxlsTemplate;
    }
}
